<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>3_类中方法this指向</title>
  </head>
  <body>
    <script>
      class Person {
        constructor(name, age) {
          this.name = name
          this.age = age
        }

        speak() {
          console.log(this)
        }
      }

      const p = new Person('why', 18)
      p.speak()

      const x = p.speak;
      x();
    </script>
  </body>
</html>
